DialogViewBase.cs
Language: C#
Last Modified: 2020-06-27 1:58:33 PM UTC
File Size: 1698 bytes
Last Modified: 2020-06-27 1:58:33 PM UTC
File Size: 1698 bytes
http://www.penguinstew.ca/example/MVVMbase/ViewBase/DialogViewBase.cs
using Penguin.MVVMBase.ViewModelBase;
namespace Penguin.MVVMBase.ViewBase
{
/// <summary>
/// The base class for Dialog views
/// </summary>
public abstract class DialogViewBase : WindowViewBase
{
#region Properties
/// <summary>
/// The viewModel as Dialog view model
/// </summary>
private IDialogViewModel DialogViewModel
{
get
{
return m_viewModel as IDialogViewModel;
}
}
#endregion
#region Constructors
/// <summary>
/// Parameterless constructor for design view
/// </summary>
public DialogViewBase() : this(new DialogViewModelBase()) { }
/// <summary>
/// Base constructor, takes viewModel as an argument and sets up event handlers
/// </summary>
/// <param name="viewModel">The viewModel for this view</param>
public DialogViewBase(IDialogViewModel viewModel)
: base(viewModel)
{
viewModel.DialogCloseRequested += m_viewModel_DialogCloseRequested;
}
#endregion
#region Event Handlers
/// <summary>
/// Event handler for DialogCloseRequested event, closes the dialog with the given result
/// </summary>
/// <param name="sender">The sender of this event</param>
/// <param name="e">RequestDialogCloseArgs containing result</param>
void m_viewModel_DialogCloseRequested(object sender, RequestDialogCloseArgs e)
{
this.DialogResult = e.Result;
}
#endregion
}
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58